﻿using System;

namespace Bit.Art.Distributed
{
    /// <summary>
    /// 整个撮合引擎的配置信息
    /// </summary>
    public class SiteConfiguration
    {
#if STAGING
        /// <summary>
        /// 检查用户级别以及余额是否足够的节点
        /// </summary>
        /// <remarks>
        /// 这个节点后续可以使用load balance的模式分摊任务
        /// </remarks>
        // TODO: 交易匹配引擎获取工作量的socket需要放到配置文件中
        public readonly static string AccountCheckEndpoint = "tcp://AccountCheckEngineServer:28886";

        /// <summary>
        /// 持久化订单到数据库中的节点
        /// </summary>
        /// <remarks>
        /// 这个节点后续可以使用load balance的模式分摊任务
        /// </remarks>
        public readonly static string PersistentOrderEndpoint = "tcp://PersistentOrderEngineServer:28887";

        /// <summary>
        /// 订单匹配引擎节点
        /// </summary>
        public readonly static string OrderMatchEndpoint = "tcp://OrderMatchEngineServer:28888";

        /// <summary>
        /// 保存订单结果的节点
        /// </summary>
        public readonly static string MatchResultSinkEndpoint = "tcp://MatchResultEngineServer:28889";

        /// <summary>
        /// 广播撮合结果的节点
        /// </summary>
        public readonly static string PublishEndpoint = "tcp://PublishEngineServer:27888";

        /// <summary>
        /// 更新订单的节点
        /// </summary>
        public readonly static string CancelOrderEndpoint = "tcp://CancelOrderEngineServer:28885";

        /// <summary>
        /// 前台API对接后台的节点
        /// </summary>
        public readonly static string FrontEndpoint = "tcp://ApiLbFrontEngineServer:23333";

        /// <summary>
        /// 后台API对接前端的节点
        /// </summary>
        public readonly static string BackEndpoint = "tcp://ApiLbBackEngineServer:26666";

        /// <summary>
        /// 与后台交易数据库交互的节点
        /// </summary>
        public readonly static string DatabaseEndpoint = "tcp://UpdateBalanceServer:25555";

        /// <summary>
        /// 处理交易对更新的节点
        /// </summary>
        public readonly static string ChangeMarketEndpoint = "tcp://OrderMatchEngineServer:28883";
#else
        /// <summary>
        /// 检查用户级别以及余额是否足够的节点
        /// </summary>
        /// <remarks>
        /// 这个节点后续可以使用load balance的模式分摊任务
        /// </remarks>
        // TODO: 交易匹配引擎获取工作量的socket需要放到配置文件中
        public readonly static string AccountCheckEndpoint = "tcp://localhost:18886";

        /// <summary>
        /// 持久化订单到数据库中的节点
        /// </summary>
        /// <remarks>
        /// 这个节点后续可以使用load balance的模式分摊任务
        /// </remarks>
        public readonly static string PersistentOrderEndpoint = "tcp://localhost:18887";

        /// <summary>
        /// 订单匹配引擎节点
        /// </summary>
        public readonly static string OrderMatchEndpoint = "tcp://localhost:18888";

        /// <summary>
        /// 保存订单结果的节点
        /// </summary>
        public readonly static string MatchResultSinkEndpoint = "tcp://localhost:18889";

#if UNITTEST
        /// <summary>
        /// 广播撮合结果的节点
        /// </summary>
        public readonly static string PublishEndpoint = "tcp://localhost:28888";
#else
        public readonly static string PublishEndpoint = "tcp://PublishEngineServer:8888";
#endif

        /// <summary>
        /// 更新订单的节点
        /// </summary>
        public readonly static string CancelOrderEndpoint = "tcp://localhost:18885";

        /// <summary>
        /// 前台API对接后台的节点
        /// </summary>
        public readonly static string FrontEndpoint = "tcp://localhost:3333";

        /// <summary>
        /// 后台API对接前端的节点
        /// </summary>
        public readonly static string BackEndpoint = "tcp://localhost:6666";

        /// <summary>
        /// 与后台交易数据库交互的节点
        /// </summary>
        public readonly static string DatabaseEndpoint = "tcp://localhost:5555";

        /// <summary>
        /// 处理交易对更新的节点
        /// </summary>
        public readonly static string ChangeMarketEndpoint = "tcp://localhost:18883";
#endif

        /// <summary>
        /// 广播的Tick主题
        /// </summary>
        public const string PUBLISH_TOPIC_TICK = "tick";

        /// <summary>
        /// 广播的order主题
        /// </summary>
        public const string PUBLISH_TOPIC_ORDER = "order";

        /// <summary>
        /// 用户下单的最小以BTC计价的交易量
        /// </summary>
        public const decimal MINIMUM_ORDER_VOLUME = 0.002m;

#if DEBUG
        // TODO: 对接SSO后删掉这个硬编码
        public const uint ACCOUNT_ID_FOR_TESTCASE = 1;
#endif

        public readonly static int PublisherSendHighWatermark = 10000;
    }
}
